package com.example.zhuyu.basemvp.base;

import android.support.multidex.MultiDexApplication;

import com.example.zhuyu.basemvp.di.component.AppComponent;
import com.example.zhuyu.basemvp.di.component.DaggerAppComponent;
import com.example.zhuyu.basemvp.di.module.AppModule;

import javax.inject.Singleton;

/**
 * @author zhuyu
 * @date 2019/2/21
 * @desc
 */
public class BaseApplication extends MultiDexApplication implements App {

    protected AppComponent mAppComponent;

    private static BaseApplication sBaseApplication;


    @Singleton
    public static BaseApplication getInstance(){
        return sBaseApplication;
    }

    @Override
    public void onCreate() {
        super.onCreate();

        sBaseApplication = this;
        mAppComponent = DaggerAppComponent
                .builder()
                .appModule(new AppModule(this))
                .build();
        mAppComponent.inject(this);

    }

    @Override
    public AppComponent getAppComponent() {
        return mAppComponent;
    }
}
